<template>
  <a-modal v-model:visible="visible" title="编辑DTU" :footer="null">
    <div class="py-8">
      <this-form @updated="updated" ref="formRef" />
    </div>
  </a-modal>
</template>
  <script lang="ts">
import { message } from 'ant-design-vue';
import { defineComponent, ref, nextTick } from 'vue';
import thisForm from './dtu-form.vue';

export default defineComponent({
  components: { thisForm },
  setup(props, { emit }) {
    const visible = ref<boolean>(false);
    const formRef = ref<any>();

    const open = (dtu) => {
      visible.value = true;
      nextTick(() => {
        formRef.value.setForm(dtu);
      });
    };

    const updated = (params) => {
      visible.value = false;
      message.success('操作成功');
      emit('updated', params);
    };

    return {
      visible,
      updated,
      open,
      formRef,
    };
  },
});
</script>
  
